package com.longcai.controller.homepage;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.longcai.bean.PageHelper;
import com.longcai.entity.company.ClyjContext;
import com.longcai.service.homepage.ClyjContextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LWK
 * @since 2019-04-08
 */
@Controller
@RequestMapping("/clyjContext")
public class ClyjContextController {

    @Autowired
    private ClyjContextService clyjContextService;

    /**
     * 获取新人手册或者公司简介
     *
     * @param context
     * @param pageHelper
     * @return
     */
    @GetMapping(value = "getContext")
    @ResponseBody
    public ClyjContext getContext(ClyjContext context, PageHelper pageHelper) {
        QueryWrapper<ClyjContext> wrapper = new QueryWrapper<ClyjContext>();
        if (context.getType() != null && context.getType() != "") {
            wrapper.eq("type", context.getType());
        }
        wrapper.eq("status", 0);
        List<ClyjContext> sysRoleIPage = this.clyjContextService.selectList(wrapper);
        if (sysRoleIPage != null && sysRoleIPage.size() > 0) {
            return sysRoleIPage.get(0);
        }
        return null;
    }

}